package com.pan.script.pantrans.util;

import java.awt.event.KeyEvent;
import java.lang.reflect.Field;
import java.util.HashMap;

public enum KeyEventMap implements RobotEventMap {
    INSTANCE;

    private HashMap<String,Integer> eventMap = new HashMap<>();
    {
        Class<KeyEvent> keyEventClass = KeyEvent.class;
        Field[] fields = keyEventClass.getFields();
        try {
            for (Field field : fields) {
                String name = field.getName();
                if (name.startsWith("VK_")) {
                    int value = (int) field.get(null);
                    eventMap.put(name.substring(3), value);
                }
            }
        } catch (IllegalAccessException e) {
            throw new RuntimeException(e);
        }
    }

    @Override
    public Integer getEventId(String key){
        return eventMap.get(key.toUpperCase());
    }


    public static void main(String[] args) {

    }
}
